﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using System.Activities.Tracking;
using ActivityLibrary; //make sure you add this reference in order to be able to use the activities  
namespace Activities
{
    public class ActivityController
    {
        private static WorkflowApplication application;
        /// <summary>  
        /// Creates an instance of the game activity and starts running it  
        /// </summary>  
        public static void StartActivity()
        {
            //input parameters for the game  
            var inputParameters = new Dictionary<string, object>() { { "MaxNumber", 100 } };
            //we create an instance of the application  
            application = new WorkflowApplication(new FlujoPrueba(), inputParameters);
            //we assign a delegate for the Completed event of the application  
            application.Completed = delegate(WorkflowApplicationCompletedEventArgs completedEvent)
            {
                CommunicateMessage.message = "Congratulations. Number of steps = " + completedEvent.Outputs["Turns"];
            };
            //we start the application  
            application.Run();
        }
        /// <summary>  
        /// Passes the number that we entered to the Game activity;  
        /// Also, we pass a message to the Game activity; this just make sure that the flow of the activity is right  
        /// </summary>  
        public static void TryGuess(int number)
        {
            application.ResumeBookmark("EnterGuess", number);
            application.ResumeBookmark("Message", "Passed");
        }
        /// <summary>  
        /// Takes the message that Game activity wants to communicate to us  
        /// </summary>  
        /// <returns>The message that will inform the user of the quality of the guess</returns>  
        public static string GetMessage()
        {
            return CommunicateMessage.message;
        }
    }
}